package strategy.order;

import java.math.BigDecimal;

/**
 * 直减
 * @author Fengdong.Duan
 * @create 2023/12/5 10:58
 */
public class ZJCouponDiscount implements ICouponDiscount<Double> {
    /**
     * 直减计算
     * 1. 使用商品价格减去优惠价格
     * 2. 最低支付金额0.1元
     */
    @Override
    public BigDecimal discountAmount(Double couponInfo, BigDecimal skuPrice) {
        BigDecimal discountAmount = skuPrice.subtract(new BigDecimal(couponInfo));
        if (discountAmount.compareTo(BigDecimal.ZERO) < 1) return BigDecimal.valueOf(0.1f);
        return discountAmount;
    }
}
